package com.newer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.newer.domain.Material;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MaterialMapper extends BaseMapper<Material> {

    @Select("select m.materialId,m.materialName,m.imgName,m.standard,m.unit,m.price,m.weight,mc.categoryName,s.supplierName from t_material m inner join t_material_category mc on m.categoryId=mc.categoryId inner join t_supplier s on m.supplierId=s.supplierId where materialName like CONCAT('%',#{name},'%')")
    @Results({
            @Result(column = "materialId",property = "materialid"),
            @Result(column = "materialName",property = "materialname"),
            @Result(column = "imgName",property = "imgname"),
            @Result(column = "standard",property = "standard"),
            @Result(column = "unit",property = "unit"),
            @Result(column = "price",property = "price"),
            @Result(column = "weight",property = "weight"),
            @Result(column = "categoryName",property = "materialCategory.categoryname"),
            @Result(column = "supplierName",property = "supplier.suppliername"),
    })
    Page<Material> selectMaterial(Page page,String name);



}